var validarCampoNumerico = function(event) {
	var keyCode = window.event ? event.keyCode : event.which;
	
	if (keyCode != 0 && keyCode != 8 && (keyCode < 48 || keyCode > 57)) {
		return false;
	}
	return true;
};

var validarCampoAlfaNumerico = function(event) {
	var keyCode = window.event ? event.keyCode : event.which;

	if (event.ctrlKey
			&& (keyCode == 120 || keyCode == 118 || keyCode == 99
					|| keyCode == 3 || keyCode == 24 || keyCode == 22)) {
		return true;
	}

	if (keyCode != 0
			&& keyCode != 8
			&& ((keyCode < 65 || keyCode > 90)
					&& (keyCode < 97 || keyCode > 122)
					&& (keyCode < 48 || keyCode > 57) && keyCode != 32
					&& keyCode != 241 && keyCode != 209 && keyCode != 225
					&& keyCode != 233 && keyCode != 237 && keyCode != 243
					&& keyCode != 250 && keyCode != 193 && keyCode != 201
					&& keyCode != 205 && keyCode != 211 && keyCode != 218)) {
		return false;
	}
	return true;
};

var longitudNumeroDoc = function(event) {
	var maxLength = 8;
	tipoDocNode = document.form.txtTipoDocumento;
	numeDocNode = document.form.txtNroDocumento;
	tipoDocNodeValue = tipoDocNode.value;
	if (tipoDocNodeValue == 1) {
		maxLength = 8;
	}
	if (tipoDocNodeValue == 2) {
		maxLength = 10;
	}
	$('input[name=txtNroDocumento]').attr('maxlength',maxLength);
	$('input[name=txtNroDocumento]').val('');
};

var validarIngresoTipoDocumento = function(event) {
	tipoDocNode = document.form.txtTipoDocumento.value;
	numeDocNode = document.form.txtNroDocumento;
	tipo = tipoDocNode.toUpperCase();
	if (tipo == 'DNI' || tipo == 'RUC'.toUpperCase()
			|| tipo == 'Carnet Extranjer\u00EDa'.toUpperCase()) {
		return validarCampoNumerico(event);
	}
	if (tipo == 'Pasaporte'.toUpperCase()) {
		return validarCampoAlfaNumerico(event);
	}
};